unit Con_FaseProcesso;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,
  Db,Dbtables, TFlatButtonUnit;

type
  TFrmCon_FaseProcesso = class(TFrmConsulta)
    Label1: TLabel;
    EdtDescricao: TEdit;
    DbgFaseProcesso: TDBGrid;
    procedure BtnFecharClick(Sender: TObject);
    procedure EdtDescricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Fase_codigo : String;
  end;

var
  FrmCon_FaseProcesso: TFrmCon_FaseProcesso;

implementation

Uses Dm, Biblio, clsFaseProcesso;

{$R *.DFM}

var FaseProcesso : TFaseProcesso;
    tds          : Tdatasource;
    tq           : Tquery;

procedure TFrmCon_FaseProcesso.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Fase_codigo:=tq.fieldbyname('Fase_codigo').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_FaseProcesso.EdtDescricaoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    EdtDescricao.setfocus;
  end;
end;

procedure TFrmCon_FaseProcesso.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(FrmCon_FaseProcesso);
  tq:=Tquery.create(FrmCon_FaseProcesso);
  tq.databasename:=dmint.db.databasename;
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  EdtDescricao.setfocus;
end;

procedure TFrmCon_FaseProcesso.FazConsulta;
begin
  if EdtDescricao.text='' then
    EdtDescricao.text := ' ';
  FaseProcesso:=TFaseProcesso.Create;
  FaseProcesso.Consultar(tq,EdtDescricao.text);
  tq.open;
  FaseProcesso.free;
  dbgFaseProcesso.DataSource := tds;
  dbgFaseProcesso.Refresh;
end;

end.
